var app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    confirm: !1,
    height: 300,
    pathArr: [],
    picPath: "",
    title: "",
    starList: [{
      text: "非常差",
      starBoo: !1
    }, {
      text: "差",
      starBoo: !1
    }, {
      text: "一般",
      starBoo: !1
    }, {
      text: "好",
      starBoo: !1
    }, {
      text: "非常好",
      starBoo: !1
    }],
    starText: "",
    chooseImageBoo: !1
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    var that = this
    var sid = options.sid
    var id = options.id
    app.util.request({
      'url': 'entry/wxapp/hzbingli.url',
      success: function(res) {
        console.log(res)
        that.setData({
          url: res.data
        })
      },
    })
    that.setData({
      sid: sid,
      id: id
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function() {

  },
  bindFormSubmit() {
    var that = this
    var estimate = that.data.estimate //文字
    var pathArr = that.data.pathArr //图片
    var dengj = that.data.dengj //星星
    var id = that.data.id
    app.util.request({
      'url': 'entry/wxapp/pinglun.goodspj',
      data: {
        openid: wx.getStorageSync('openid'),
        text: estimate,
        sid: that.data.sid,
        dengj: dengj,
        pic: pathArr,
        id:id
      },
      success: function(res) {
        console.log(res)
        var pages = getCurrentPages();
        var prevPage = pages[pages.length - 2];
        prevPage.setData({
          plstate: 1
        })
        wx.navigateBack({
          detail: 1
        })
        wx.showToast({
          title: '评价成功',
          icon: 'none'
        })
      }
    })
  },
  chooseImage: function() {
    var that = this
    var pathArr = that.data.pathArr
    var uniacid = app.siteInfo.uniacid
    wx.chooseImage({
      count: 9,
      sizeType: ["original", "compressed"],
      sourceType: ["album", "camera"],
      success: function(e) {
        const tempFilePaths = e.tempFilePaths
        for (var o = e.tempFilePaths, i = 0; i < o.length; i++)
          if (pathArr.length >= 9) {
            that.setData({
              chooseImageBoo: !0
            });
            break;
          } else {
            wx.uploadFile({
              url: that.data.url + 'app/index.php?i=' + uniacid + '&c=entry&a=wxapp&do=Uploadback&m=hyb_yl',
              filePath: tempFilePaths[i],
              name: 'upfile',
              formData: {},
              success: function(res) {
                console.log(res)
                pathArr.push(res.data)
                that.setData({
                  pathArr: pathArr
                })
              }
            })
          }

      }
    });
  },
  bindblur: function(t) {
    var a = t.detail.value;
    this.setData({
      estimate: a
    });
  },
  changeStar: function(t) {
    console.log(t)
    for (var a = t.target.dataset.current, e = this.data.starList, o = 0; o < e.length; o++) e[o].starBoo = o <= a;
    this.setData({
      starList: e,
      starText: e[a].text,
      dengj: t.target.dataset.current
    });
  },
})